import Vue from 'vue'
import VueRouter from 'vue-router'
import {$storage} from './assets/js/boss';

Vue.use(VueRouter);

export const router = new VueRouter({
  mode: 'history',
  base: '/',
  routes: [
    {path: '/home', name: 'home', component: () => import('@/views/home/home_page')},
    {path: '/', name: 'Index', component: () => import('@/views/Index')},
    {path: '/login', name: 'Login', component: () => import('@/views/Login')},
    {path: '/welcome', name: 'welcome', component: () => import('@/views/welcome')},
    {path: '/own/staff/edit', name: 'own_staff_edit', component: () => import('@/views/own_staff_edit')},
    {path: '/own/staff/pwd', name: 'own_staff_pwd', component: () => import('@/views/own_staff_pwd')},
    {path: '/logs/login', name: 'log_login', component: () => import('@/views/logs/log_login')},
    {path: '/logs/login/info', name: 'log_login_info', component: () => import('@/views/logs/log_login_info')},
    {path: '/logs/operation', name: 'log_operation', component: () => import('@/views/logs/log_operation')},
    {path: '/logs/operation/info', name: 'log_operation_info', component: () => import('@/views/logs/log_operation_info')},
    {path: '/sys/staff', name: 'staff', component: () => import('@/views/sys/staff')},
    {path: '/sys/staff/edit', name: 'staff_edit', component: () => import('@/views/sys/staff_edit')},
    {path: '/sys/staff/edit/role', name: 'staff_edit_role', component: () => import('@/views/sys/staff_edit_role')},
    {path: '/sys/staff/info', name: 'staff_info', component: () => import('@/views/sys/staff_info')},
    {path: '/sys/auth/perm', name: 'auth_perm', component: () => import('@/views/sys/auth_perm')},
    {path: '/sys/auth/perm/edit', name: 'auth_perm_edit', component: () => import('@/views/sys/auth_perm_edit')},
    {path: '/sys/auth/perm/info', name: 'auth_perm_info', component: () => import('@/views/sys/auth_perm_info')},
    {path: '/sys/auth/role', name: 'auth_role', component: () => import('@/views/sys/auth_role')},
    {path: '/sys/auth/role/edit', name: 'auth_role_edit', component: () => import('@/views/sys/auth_role_edit')},
    {path: '/sys/auth/role/user', name: 'auth_role_user', component: () => import('@/views/sys/auth_role_user')},
    {path: '/sys/variable', name: 'sys_variable', component: () => import('@/views/sys/sys_variable')},
    {path: '/sys/variable/edit', name: 'sys_variable_edit', component: () => import('@/views/sys/sys_variable_edit')},
    // 综合展示
    {path: '/home/show_page', name: 'show_show_page', component: () => import('@/views/home/show_page')},
    // 一张图
    {path: '/one/one_page', name: 'one_one_page', component: () => import('@/views/one/one_page')},
    {path: '/map/mapll', name: 'mapll', component: () => import('@/views/map/mapll')},
    {path: '/map/none', name: 'none', component: () => import('@/views/map/none')},
    {path: '/map/index', name: 'none', component: () => import('@/views/map/index')}, // 一张图
    {path: '/staff/riverSupervisor', name: 'riverSupervisor', component: () => import('@/views/staff/river_supervisor')},
    {path: '/staff/riverSupervisor/edit', name: 'riverSupervisorEdit', component: () => import('@/views/staff/river_supervisor_edit')},
    {path: '/staff/riverSupervisor/info', name: 'riverSupervisorInfo', component: () => import('@/views/staff/river_supervisor_info')},
    {path: '/staff/riverStaff', name: 'riverStaff', component: () => import('@/views/staff/river_staff')},
    {path: '/staff/riverStaff/edit', name: 'riverStaffEdit', component: () => import('@/views/staff/river_staff_edit')},
    {path: '/staff/riverStaff/info', name: 'riverStaffInfo', component: () => import('@/views/staff/river_staff_info')},
    {path: '/staff/orgInfo', name: 'orgInfo', component: () => import('@/views/staff/org_info')},
    {path: '/staff/orgInfo/edit', name: 'orgInfoEdit', component: () => import('@/views/staff/org_info_edit')},
    {path: '/staff/orgInfo/info', name: 'orgInfoInfo', component: () => import('@/views/staff/org_info_info')},
    // 巡查管理-本级河长日志
    {path: '/river/longRiverLog', name: 'long_river_log', component: () => import('@/views/river/long_river_log')},
    {path: '/river/longRiverLog/edit', name: 'long_river_log_edit', component: () => import('@/views/river/long_river_log_edit')},
    // 河湖档案-一河一档
    {path: '/river/riverRecord', name: 'river_record', component: () => import('@/views/river/river_record')},
    // 河湖档案-河道名录
    {path: '/river/riverInfo', name: 'river_info', component: () => import('@/views/river/river_info')},
    {path: '/river/riverInfo/edit', name: 'river_info_edit', component: () => import('@/views/river/river_info_edit')},
    // 河湖档案-渠道信息
    {path: '/river/channelInfo', name: 'channel_info', component: () => import('@/views/river/channel_info')},
    {path: '/river/channelInfo/edit', name: 'channel_info_edit', component: () => import('@/views/river/channel_info_edit')},
    // 河湖档案-水库名录
    {path: '/river/reservoirInfo', name: 'reservoir_info', component: () => import('@/views/river/reservoir_info')},
    {path: '/river/reservoirInfo/edit', name: 'reservoir_info_edit', component: () => import('@/views/river/reservoir_info_edit')},
    // 河湖档案-取水口信息
    {path: '/river/intakeInfo', name: 'intake_info', component: () => import('@/views/river/intake_info')},
    {path: '/river/intakeInfo/edit', name: 'intake_info_edit', component: () => import('@/views/river/intake_info_edit')},
    // 河湖档案-排污口信息
    {path: '/river/drainOutlet', name: 'drain_outlet', component: () => import('@/views/river/drain_outlet')},
    {path: '/river/drainOutlet/edit', name: 'drain_outlet_edit', component: () => import('@/views/river/drain_outlet_edit')},
    // 河湖档案-河长公示牌
    {path: '/river/riverBillboard', name: 'river_billboard', component: () => import('@/views/river/river_billboard')},
    {path: '/river/riverBillboard/edit', name: 'river_billboard_edit', component: () => import('@/views/river/river_billboard_edit')},
    // 河湖档案-一河一策
    {path: '/river/riverPolicy', name: 'river_policy', component: () => import('@/views/river/river_policy')},
    {path: '/river/riverPolicy/edit', name: 'river_policy_edit', component: () => import('@/views/river/river_policy_edit')},
    // 河湖档案-污水处理
    {path: '/river/sewageTreatment', name: 'sewage_treatment', component: () => import('@/views/river/sewage_treatment')},
    {path: '/river/sewageTreatment/edit', name: 'sewage_treatment_edit', component: () => import('@/views/river/sewage_treatment_edit')},
    {path: '/river/water_function_info', name: 'river_water_function_info', component: () => import('@/views/river/water_function_info')},
    {path: '/river/water_function_info/edit', name: 'river_water_function_info_edit', component: () => import('@/views/river/water_function_info_edit')},
    {path: '/river/drinkingwater_source', name: 'river_drinkingwater_source', component: () => import('@/views/river/drinkingwater_source')},
    {path: '/river/drinkingwater_source/info', name: 'river_drinkingwater_source_info', component: () => import('@/views/river/drinkingwater_source_info')},
    {path: '/river/drinkingwater_source/edit', name: 'river_drinkingwater_source_edit', component: () => import('@/views/river/drinkingwater_source_edit')},
    {path: '/river/water_protection_area', name: 'river_water_protection_area', component: () => import('@/views/river/water_protection_area')},
    {path: '/river/water_protection_area/edit', name: 'river_water_protection_area_edit', component: () => import('@/views/river/water_protection_area_edit')},
    {path: '/river/water_shoreline', name: 'river_water_shoreline', component: () => import('@/views/river/water_shoreline')},
    {path: '/river/water_shoreline/edit', name: 'river_water_shoreline_edit', component: () => import('@/views/river/water_shoreline_edit')},
    {path: '/river/cases', name: 'river_cases', component: () => import('@/views/river/cases')},
    {path: '/river/cases/info', name: 'river_cases_info', component: () => import('@/views/river/cases_info')},
    {path: '/river/cases/edit', name: 'river_cases_edit', component: () => import('@/views/river/cases_edit')},
    {path: '/river/pump_gate', name: 'river_pump_gate', component: () => import('@/views/river/pump_gate')},
    {path: '/river/pump_gate/info', name: 'river_pump_gate_info', component: () => import('@/views/river/pump_gate_info')},
    {path: '/river/pump_gate/edit', name: 'river_pump_gate_edit', component: () => import('@/views/river/pump_gate_edit')},
    {path: '/river/station', name: 'river_station', component: () => import('@/views/river/station')},
    {path: '/river/station/info', name: 'river_station_info', component: () => import('@/views/river/station_info')},
    {path: '/river/station/edit', name: 'river_station_edit', component: () => import('@/views/river/station_edit')},
    // 生态流量
    {path: '/flow/map', name: 'flow_map', component: () => import('@/views/flow/map')},
    {path: '/flow/hpb', name: 'flow_hpb', component: () => import('@/views/flow/hpb')},
    {path: '/flow/flow', name: 'flow_flow', component: () => import('@/views/flow/flow')},
    {path: '/flow/index', name: 'flow_index', component: () => import('@/views/flow/index')},
    {path: '/flow/video', name: 'flow_video', component: () => import('@/views/flow/video')},
    // 巡查管理
    {path: '/patrol/inspection_plan', name: 'patrol_inspection_plan', component: () => import('@/views/patrol/inspection_plan')},
    {path: '/patrol/inspection_plan/info', name: 'patrol_inspection_plan_info', component: () => import('@/views/patrol/inspection_plan_info')},
    {path: '/patrol/inspection_plan/edit', name: 'patrol_inspection_plan_edit', component: () => import('@/views/patrol/inspection_plan_edit')},
    {path: '/patrol/patrol_task', name: 'patrol_patrol_task', component: () => import('@/views/patrol/patrol_task')},
    {path: '/patrol/patrol_task/info', name: 'patrol_patrol_task_info', component: () => import('@/views/patrol/patrol_task_info')},
    {path: '/patrol/patrol_task/edit', name: 'patrol_patrol_task_edit', component: () => import('@/views/patrol/patrol_task_edit')},
    // 完成情况统计
    {path: '/patrol/completion_stat', name: 'patrol_completion_stat', component: () => import('@/views/patrol/completion_stat')},
    // 本级河长日志
    {path: '/patrol/patrol_log_peer', name: 'patrol_patrol_log_peer', component: () => import('@/views/patrol/patrol_log_peer')},
    // 下级河长日志
    {path: '/patrol/patrol_log_junior', name: 'patrol_patrol_log_junior', component: () => import('@/views/patrol/patrol_log_junior')},
    // 河长日志详情
    {path: '/patrol/log_detail/:id', name: 'patrol_log_detail', component: () => import('@/views/patrol/log_detail')},
    {path: '/report/reportBimonthly', name: 'reportBimonthly', component: () => import('@/views/report/report_bimonthly')},
    {path: '/report/reportBimonthly/edit', name: 'reportBimonthlyEdit', component: () => import('@/views/report/report_bimonthly_edit')},
    {path: '/report/reportBimonthly/info', name: 'reportBimonthlyInfo', component: () => import('@/views/report/report_bimonthly_info')},
    {path: '/report/reportMonthly', name: 'reportMonthly', component: () => import('@/views/report/report_monthly')},
    {path: '/report/reportMonthly/edit', name: 'reportMonthlyEdit', component: () => import('@/views/report/report_monthly_edit')},
    {path: '/report/reportMonthly/info', name: 'reportMonthlyInfo', component: () => import('@/views/report/report_monthly_info')},
    {path: '/report/reportTenday', name: 'reportTenday', component: () => import('@/views/report/report_tenday')},
    {path: '/report/reportTenday/edit', name: 'reportTendayEdit', component: () => import('@/views/report/report_tenday_edit')},
    {path: '/report/reportTenday/info', name: 'reportTendayInfo', component: () => import('@/views/report/report_tenday_info')},
    {path: '/report/reportYear', name: 'reportYear', component: () => import('@/views/report/report_year')},
    {path: '/report/reportYear/edit', name: 'reportYearEdit', component: () => import('@/views/report/report_year_edit')},
    {path: '/report/reportYear/info', name: 'reportYearInfo', component: () => import('@/views/report/report_year_info')},
    {path: '/report/reportWorkBrief', name: 'reportWorkBrief', component: () => import('@/views/report/report_work_brief')},
    {path: '/report/reportWorkBrief/edit', name: 'reportWorkBriefEdit', component: () => import('@/views/report/report_work_brief_edit')},
    {path: '/report/reportWorkBrief/info', name: 'reportWorkBriefInfo', component: () => import('@/views/report/report_work_brief_info')},
    {path: '/report/reportTask', name: 'reportTask', component: () => import('@/views/report/report_task')},
    {path: '/report/reportTask/edit', name: 'reportTaskEdit', component: () => import('@/views/report/report_task_edit')},
    {path: '/report/reportTask/info', name: 'reportTaskInfo', component: () => import('@/views/report/report_task_info')},
    {path: '/report/reportTask/item/page', name: 'reportTaskItemPage', component: () => import('@/views/report/report_task_item_page')},
    {path: '/report/reportTask/item/audit', name: 'reportTaskItemAudit', component: () => import('@/views/report/report_task_item_audit')},
    {path: '/report/reportTask/item/preview', name: 'report_task_item_preview', component: () => import('@/views/report/report_task_item_preview')},
    {path: '/report/reportTaskSubmit', name: 'reportTaskSubmit', component: () => import('@/views/report/report_task_submit')},
    {path: '/report/reportTaskSubmit/edit', name: 'reportTaskSubmitEdit', component: () => import('@/views/report/report_task_submit_edit')},
    {path: '/report/reportTaskSubmit/info/audit', name: 'reportTaskSubmitInfoAudit', component: () => import('@/views/report/report_task_submit_info_audit')},
    {path: '/report/reportEvent/patrol', name: 'reportEventPatrol', component: () => import('@/views/report/report_event_patrol')},
    {path: '/report/reportEvent/complaint', name: 'reportEventComplaint', component: () => import('@/views/report/report_event_complaint')},
    {path: '/report/reportEvent/info', name: 'reportEventInfo', component: () => import('@/views/report/report_event_info')},
    {path: '/report/reportEvent/supervision', name: 'reportEventSupervision', component: () => import('@/views/report/report_event_supervision')},
    {path: '/report/reportEvent/treatment', name: 'reportEventTreatment', component: () => import('@/views/report/report_event_treatment')},
    {path: '/sys/orgInfo', name: 'sysOrgInfo', component: () => import('@/views/sys/org_info')},
    {path: '/sys/sysNews/faq', name: 'sysNewsFAQ', component: () => import('@/views/sys/sys_news_faq')},
    {path: '/sys/sysNews/faq/edit', name: 'sysNewsFAQEdit', component: () => import('@/views/sys/sys_news_faq_edit')},
    {path: '/sys/sysNews/notice', name: 'sysNewsNotice', component: () => import('@/views/sys/sys_news_notice')},
    {path: '/sys/sysNews/notice/edit', name: 'sysNewsNoticeEdit', component: () => import('@/views/sys/sys_news_notice_edit')},
    {path: '/sys/sysNews/trends', name: 'sysNewsTrends', component: () => import('@/views/sys/sys_news_trends')},
    {path: '/sys/sysNews/trends/edit', name: 'sysNewsTrendsEdit', component: () => import('@/views/sys/sys_news_trends_edit')},
    {path: '/sys/sysNews/policy', name: 'sysNewsPolicy', component: () => import('@/views/sys/sys_news_policy')},
    {path: '/sys/sysNews/policy/edit', name: 'sysNewsPolicyEdit', component: () => import('@/views/sys/sys_news_policy_edit')},
    {path: '/sys/sysNews/water', name: 'sysNewsWater', component: () => import('@/views/sys/sys_news_water')},
    {path: '/sys/sysNews/water/edit', name: 'sysNewsWaterEdit', component: () => import('@/views/sys/sys_news_water_edit')},
    {path: '/sys/sysNews/reprint', name: 'sysNewsReprint', component: () => import('@/views/sys/sys_news_reprint')},
    {path: '/sys/sysNews/reprint/edit', name: 'sysNewsReprintEdit', component: () => import('@/views/sys/sys_news_reprint_edit')},
    // 目标考核-主要目标
    {path: '/examine/examineMainTarget', name: 'examineMainTarget', component: () => import('@/views/examine/examine_main_target')},
    {path: '/examine/examineMainTarget/edit', name: 'examineMainTargetEdit', component: () => import('@/views/examine/examine_main_target_edit')},
    // 目标考核-考核指标
    {path: '/examine/examineTarget', name: 'examineTarget', component: () => import('@/views/examine/examine_target')},
    {path: '/examine/examineTargetImport', name: 'examineTargetImport', component: () => import('@/views/examine/examine_target_import')},
    {path: '/examine/examineTarget/edit', name: 'examineTargetEdit', component: () => import('@/views/examine/examine_target_edit')},
    // 目标考核-考核指标详细
    {path: '/examine/examineTargetDetail', name: 'examineTargetDetail', component: () => import('@/views/examine/examine_target_detail')},
    {path: '/examine/examineTargetDetail/edit', name: 'examineTargetDetailEdit', component: () => import('@/views/examine/examine_target_detail_edit')},
    // 目标考核-考核评估
    {path: '/examine/examineEvaluate', name: 'examineEvaluate', component: () => import('@/views/examine/examine_evaluate')},
    {path: '/examine/examineEvaluate/edit', name: 'examineEvaluateEdit', component: () => import('@/views/examine/examine_evaluate_edit')},
    // 目标考核-考核结果
    {path: '/examine/examineResult', name: 'examineResult', component: () => import('@/views/examine/examine_result')},
    {path: '/examine/examineResult/edit', name: 'examineResultEdit', component: () => import('@/views/examine/examine_result_edit')},
    // 目标考核-考核自评
    {path: '/examine/examineSelfEvaluation', name: 'examineSelfEvaluation', component: () => import('@/views/examine/examine_self_evaluation')},
    {path: '/examine/examineSelfEvaluation/edit', name: 'examineSelfEvaluationEdit', component: () => import('@/views/examine/examine_self_evaluation_edit')},
    // 目标考核-上级评分
    {path: '/examine/examineLeaderEvaluation', name: 'examineLeaderEvaluation', component: () => import('@/views/examine/examine_leader_evaluation')},
    {path: '/examine/examineLeaderEvaluation/edit', name: 'examineLeaderEvaluationEdit', component: () => import('@/views/examine/examine_leader_evaluation_edit')},
    // 统计分析
    {path: '/analysis/river/supervisor', name: 'analysis_river_supervisor', component: () => import('@/views/analysis/analysis_river_supervisor')},
    {path: '/analysis/river/reach', name: 'analysis_river_reach', component: () => import('@/views/analysis/analysis_river_reach')},
    {path: '/analysis/patrol', name: 'analysis_patrol', component: () => import('@/views/analysis/analysis_patrol')},
    {path: '/analysis/water', name: 'analysis_water', component: () => import('@/views/analysis/analysis_water')},
    {path: '/analysis/complaint/treatment', name: 'analysis_complaint_treatment', component: () => import('@/views/analysis/analysis_complaint_treatment')},
    {path: '/analysis/complaint/type', name: 'analysis_complaint_type', component: () => import('@/views/analysis/analysis_complaint_type')},
    {path: '/analysis/event/treatment', name: 'analysis_event_treatment', component: () => import('@/views/analysis/analysis_event_treatment')},
    {path: '/analysis/event/type', name: 'analysis_event_type', component: () => import('@/views/analysis/analysis_event_type')},
    {path: '/analysis/examine/ranking', name: 'analysis_examine_ranking', component: () => import('@/views/analysis/analysis_examine_ranking')},
    {path: '/analysis/examine/level', name: 'analysis_examine_level', component: () => import('@/views/analysis/analysis_examine_level')},
    {path: '/sys/feedback', name: 'feedback', component: () => import('@/views/sys/feedback')},
    {path: '/sys/feedback/info', name: 'feedbackInfo', component: () => import('@/views/sys/feedback_info')},
    // 政策宣传
    {path: '/sys/sysNews/publicity', name: 'sysNewsPublicity', component: () => import('@/views/sys/sys_news_publicity')},
    {path: '/sys/sysNews/publicity/edit', name: 'sysNewsPublicityEdit', component: () => import('@/views/sys/sys_news_publicity_edit')},
    // 微信公众号页面
    {path: '/wechat/complain/add', name: 'wechat_complain', component: () => import('@/views/wechat/complain'), meta: {title: '公众投诉', keepAlive: false}},
    {path: '/wechat/riverList', name: 'wechat_riverList', component: () => import('@/views/wechat/riverList'), meta: {title: '河湖档案', keepAlive: false}},
    {path: '/wechat/riverInfo', name: 'wechat_riverInfo', component: () => import('@/views/wechat/riverInfo'), meta: {title: '河湖档案明细', keepAlive: false}},
    {path: '/wechat/noticeList', name: 'wechat_noticeList', component: () => import('@/views/wechat/noticeList'), meta: {title: '知识园地', keepAlive: false}},
    {path: '/wechat/newsDetail', name: 'wechat_newsDetail', component: () => import('@/views/wechat/newsDetail'), meta: {title: '详情', keepAlive: false}},
    {path: '/wechat/publicityList', name: 'wechat_publicityList', component: () => import('@/views/wechat/publicityList'), meta: {title: '宣传引导', keepAlive: false}},
    {path: '/wechat/publicityDetail', name: 'wechat_publicityDetail', component: () => import('@/views/wechat/publicityDetail'), meta: {title: '宣传引导-投票', keepAlive: false}},
    {path: '/wechat/reprintedList', name: 'wechat_reprintedList', component: () => import('@/views/wechat/reprintedList'), meta: {title: '转载文章', keepAlive: false}},
    {path: '/wechat/policyList', name: 'wechat_policyList', component: () => import('@/views/wechat/policyList'), meta: {title: '政策新闻', keepAlive: false}},
    {path: '/wechat/gzhList', name: 'wechat_gzhList', component: () => import('@/views/wechat/gzhList'), meta: {title: '镇级公众号', keepAlive: false}},
    {path: '/wechat/gzhImg', name: 'wechat_gzhImg', component: () => import('@/views/wechat/gzhImg'), meta: {title: '公众号二维码', keepAlive: false}},
    // 系统公告-操作手册
    {path: '/sys/newsManual/edit', name: 'sys_news_manual_edit', component: () => import('@/views/sys/sys_news_manual_edit')},
    {path: '/sys/newsManual/info', name: 'sys_news_manual_info', component: () => import('@/views/sys/sys_news_manual_info')}
  ]
});
/**
 * 重写路由的push方法
 */
const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => error)
}
router.beforeEach((to, from, next) => {
  // 用你的方式获取登录的用户信息
  var expMillis = 0;
  if ($storage.getItem('tokenExpMillis')) {
    expMillis = $storage.getItem('tokenExpMillis') - (new Date().getTime());
  }
  // console.info($storage.getItem('staff'))
  if (to.name === 'Login' || to.name.indexOf('wechat') > -1 || $storage.getItem('staff') && expMillis > 0) {
    //   console.info('=======next====' + to.path)
    // 如果存在用户信息，或者进入的页面是登录页面，则直接进入
    next()
  } else {
    //   console.info('=======login====')
    // 不存在用户信息则说明用户未登录，跳转到登录页面，带上当前的页面地址，登录完成后做回跳，
    // 如未登录用户进入用户中心的页面地址，检测到未登录，
    // 自动跳转到登录页面，并且带上用户中心的页面地址，登录完成后重新跳到个人中心页面。
    next({
      path: '/login'
    })
  }
})
